<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <input type="hidden" name="parentId" value="${upAuth.parentId}" >
    <div class="layui-form-item">
        <label class="layui-form-label required">操作编号为:</label>
        <div class="layui-input-block">
            <input type="text" name="rid" value="${upAuth.rid}" class="layui-input" disabled>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">是否是菜单</label>
        <div class="layui-input-block">
            <input type="checkbox" name="isMenu" ${upAuth.isMenu==1?"checked":""} lay-skin="switch" lay-filter="switchTest" lay-text="是|否">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">父菜单名称</label>
        <div class="layui-input-block">
            <input type="text" name="parentIds" disabled value="${upAuth.parentIdView}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">菜单等级</label>
        <div class="layui-input-block">
            <input type="text" name="menuLevel" value="${upAuth.menuLevel}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" lay-verify="required" lay-reqtext="名称不能为空" value="${upAuth.name}" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">URL路径</label>
        <div class="layui-input-block">
            <input type="text" name="url" value="${upAuth.url}" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="${pageContext.request.contextPath}/layui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/layui/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['form', 'tableSelect'], function () {
        var form = layui.form,
            layer = layui.layer,
            tableSelect = layui.tableSelect,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            let isMenu = data.field.isMenu;
            if(isMenu=="on"){
                data.field.isMenu=1;
            }else{
                data.field.isMenu=0;
            }

            $.ajax({
                url:"${pageContext.request.contextPath}/auth/updateAuth",
                type:"post",
                data:"data="+JSON.stringify(data.field),
                dataType:"text",
                success:(rs)=>{
                    if(rs=="OK"){
                        layer.msg("修改成功",{icon:1,time:500},function (){
                            parent.location.reload();
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                        })
                    }else{
                        layer.msg("修改失败",{icon:2,time:500})
                    }
                }
            })
        });
        return false;

    });
</script>
</body>
</html>